package com.antonio081014.arielclock;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TimePicker;
import android.widget.TimePicker.OnTimeChangedListener;

public class CreateAlarm extends Activity {

	private TimePicker tp;
	private Button btn_createAlarm;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.create_alarm);
		tp = (TimePicker) findViewById(R.id.timePickerAlarm);
		tp.setOnTimeChangedListener(TimePickerTimeChangedListener);
		btn_createAlarm = (Button) findViewById(R.id.btn_createAlarm);
		btn_createAlarm.setOnClickListener(myOnClickListener);
	}

	private OnTimeChangedListener TimePickerTimeChangedListener = new OnTimeChangedListener() {
		@Override
		public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
			// TODO Auto-generated method stub
			displayTimeDemo(hourOfDay, minute);
		}
	};

	private void displayTimeDemo(int hour, int minute) {
		EditText et = (EditText) findViewById(R.id.editText_alarm);
		String str = "Alarm Time: ";
		String pm = "am";
		if (hour >= 12)
			pm = "pm";

		if (hour > 12) {
			hour %= 12;
		}
		str += String.format("%02d", hour);
		str += ":";
		str += String.format("%02d", minute);
		str += String.format(" %s", pm);
		et.setText(str);

	}

	private View.OnClickListener myOnClickListener = new View.OnClickListener() {

		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			createOneAlarm();
		}
	};

	private void createOneAlarm() {
	}
}
